/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package DataSelection;

/**
 *
 * @author Manuel
 */
public class Query {
    
    private String select;
    private String from;
    private String group;
    private String where;
    private String having;

    public Query(){
        select = "";
        from = "";
        group = "";
        where = "";
        having = "";
    }

    public String getFrom() {
        return from;
    }

    public void setFrom(String from) {
        this.from = from;
    }

    public String getGroup() {
        return group;
    }

    public void setGroup(String group) {
        this.group = group;
    }

    public String getHaving() {
        return having;
    }

    public void setHaving(String having) {
        this.having = having;
    }

    public String getSelect() {
        return select;
    }

    public void setSelect(String select) {
        this.select = select;
    }

    public String getWhere() {
        return where;
    }

    public void setWhere(String where) {
        this.where = where;
    }

    public String generateString() {
        String query = "SELECT "+this.getSelect()+" FROM "+this.getFrom();
        if(!this.where.equals(""))
            query+=" WHERE "+this.getWhere();
        if(!this.group.equals(""))
            query+=" GROUP BY "+this.getGroup();
        if(!this.having.equals(""))
            query+=" HAVING "+this.getHaving();

        return query;
    }



}
